<template>
    <el-input v-model="currentValue"
              ref="input"
              maxlength='50'
              class="searchInput"
              placeholder="请输入"
              :clearable="clearable"
              suffix-icon="el-icon-search"
              @input="onKeyUp"
              type="text">
    </el-input>
</template>
<script>
    export default {
        name: 'searchInput',
        currentValue: String,
        oldValue: String,

        data() {
            return {
                currentValue: this.value,
            };
        },

        watch: {
            value(val, oldValue) {
                this.setCurrentValue(val);
            },
        },



        created: function () {

        },

        methods: {
            setCurrentValue(val) {
                this.currentValue = val;
            },

            onKeyUp() {
                const me = this;
                me.$emit('input', me.currentValue);
                me.$emit('value', me.currentValue);
            },
        },

        props: {
            placeholder: {
                type: String,
                default: ''
            },
            value: {
                type: String
            },
            clearable:{
                type: Boolean,
                default: true
            }
        },
    }
</script>
